<jsp:directive.page session="true" />
<%@ page import="org.biojava.services.das.dao.RegistryUser" %>
<%@ page import="org.biojava.services.das.registry.UserManager" %>
<jsp:directive.page import="org.biojava.services.das.dao.ProjectBean"/>
<jsp:useBean id="coord" class="dasregistry.coordBean" scope="page"/>
<%@ include file="sangerheader.jsp"%>
<% 
  
	if ( email == null) {		
		response.sendRedirect("login.jsp");	
		return;
	}

	String projectID = request.getParameter("projectID");
	int project_id = -1;
	if (projectID != null)
		try {
			project_id = Integer.parseInt(projectID);
		} catch(Exception e){
			out.print(e.getMessage());
		}
	ProjectBean project = coord.getProject(project_id);
	if ( project == null ) {
		project = new ProjectBean();
	}
	
	
		RegistryUser owner = project.getOwner();
		if (owner == null)
			owner = new RegistryUser();
		
%>

<%
	String title = "Edit Project " + project.getName();
	String header = title;
%>





<div id="main">
<%
String message = (String)request.getAttribute("message") ;
if (message != null) {
%>
<p><strong><%=message%></strong></p>
<%
}
%>

<h2>Project data:</h2>

<% int size=30; %>


<form 	id="projecteaction" 
		name="projecteaction" 
		action="ProjectAction" 
		method="POST" 
		enctype="multipart/form-data">
		
<input type="hidden" name="projectID" value="<%=project.getProjectID() %>"/>	
<input type="hidden" name="action" value="update"/>	

<table>
<tr><td>icon:</td>
	<td><img src="ProjectIcon?id=<%=project.getProjectID()%>"/>
	</td>
	<td><input type="file" name="file" size="<%=size %>" value="<%
	if ( request.getAttribute("file") != null ) 
		out.print(request.getAttribute("file"));

%>"/></td>
	</tr>

<tr>
<td>Name:</td>				
<td><%=project.getName() %></td>
<td><input type="text" size="<%=size %>" name="projectName" value="<%=project.getName()%>"/></td>
</tr>
	
<tr><td>homepage:</td>	
<td><a href="<%=project.getHomepage() %>"><%=project.getHomepage() %></a>
</td>
<td><input type="text" size="<%=size %>" name="projectUrl" value="<%=project.getHomepage() %>"/></td>
</tr>

<tr><td>owner:</td>
	<td><%=owner.getEmail() %></td></tr>

<tr><td>description</td>	
	<td><%=project.getDescription() %></td>
	<td>
	<textarea rows="5" cols="<%=size %>" name="projectDesc" ><%= project.getDescription()%></textarea>
	</tr>
	
<tr><td>Nr DAS sources:</td>	
	<td><a href="showProjectDetails.jsp?project_id=<%=project.getProjectID()%>"><%= coord.getNrDasSourcesForProject(project) %></a></td></tr>

<tr>
<td></td>
<td><input type="submit" value="update project"/></td><td></td>
</tr>

</table>

</form>



</div>

<%@ include file="sangerfooter.jsp"%>
